package basic

import (
	"fmt"
	"reflect"
)

// Add takes two integers and returns their sum.
func Add(a, b int) int {
	return a + b
}

func FloatReflect() bool {
	var x float64 = 3.14
	fmt.Println("type", reflect.TypeOf(x))

	return true
}

func FloatValueReflect() bool {
	var x float64 = 3.4
	v := reflect.ValueOf(x)

	fmt.Println("value:", v)
	fmt.Println("type :", v.Type())

	fmt.Println("kind is float64:", v.Kind() == reflect.Float64)
	if v.Kind() == reflect.Float64 {
		return true
	}
	return false
}

type T struct {
	A int
	B string
}

func (t *T) Hello(name string) string {
	return fmt.Sprintf("Hello, %s!", name)
}

func BasicReflectMethodCall() bool {
	t := &T{23, "hello"}
	s := reflect.ValueOf(t).MethodByName("Hello")
	args := []reflect.Value{reflect.ValueOf("Alice")}
	result := s.Call(args)
	fmt.Println(result[0].String()) // Output: Hello, Alice!
	return true
}
